package com.focusit.plurarization;

public class Example {

    public static void main(String[] args) {
        Pluralize pluralizator = new Pluralize();

        // Russian pluraliation rules found at
        // http://unicode.org/repos/cldr-tmp/trunk/diff/supplemental/language_plural_rules.html
        pluralizator.setRules(new PluralizationRules() {

            public PluralForm getPluralForm(int n) {
                if (n % 10 == 1 && n % 100 != 11) {
                    return PluralForm.one;
                }

                if ((n % 10 >= 2 && n % 10 <= 4) && !(n % 100 >= 12 && n % 100 <= 14)) {
                    return PluralForm.few;
                }

                if (n % 10 == 0 || (n % 10 >= 5 && n % 10 <= 9) || (n % 100 >= 11 && n % 100 <= 14)) {
                    return PluralForm.many;
                }

                return PluralForm.other;
            }
        });

        int n = 0;
        System.out.println(n + " " + pluralizator.getString(n, new FullWordForm("Час, часов, часов")));

        n = 100;
        System.out.println(n + " " + pluralizator.getString(n, new FullWordForm("Час, часов, часов")));
    }
}
